home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9339 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: hoho.quake.net!usenet
  2. From: gomberg@wcf.com
  3. Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1
  4. Subject: Re: GOTO controversy
  5. Date: 9 Mar 1996 16:48:00 GMT
  6. Organization: QuakeNet Internet Services (email info@Quake.Net)
  7. Message-ID: <4hsco0$rj5@hoho.quake.net>
  8. References: <rcshlds.1.000A6705@mailserv.mta.ca> <Dn8pJ8.nqs@emi.net> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net> <DnwCxp.84C@clw.cs.man.ac.uk>
  9. Reply-To: gomberg@wcf.com
  10. NNTP-Posting-Host: l87.ip.quake.net
  11. X-Newsreader: IBM NewsReader/2 v1.09
  12.  
  13. This is goto-free and I think equally clear:>>>------------------------------------------------------------------------------
  14.   HEV    hev1, hev2, hev3;     /* Event semaphores */
  15.   HMTX   hmtx;                 /* Mutex semaphore  */ 
  16.   void  *ptr;              
  17.   if DosCreateEventSem(0, &hev1, 0, FALSE) then do;    
  18.    if DosCreateEventSem(0, &hev2, 0, FALSE) then do;
  19.     if DosCreateEventSem(0, &hev3, 0, FALSE) then do;
  20.      if DosCreateMutexSem(0, &hmtx, 0, FALSE) then do;
  21.       ptr = malloc(SOME_SIZE)
  22.       if ptr<>NULL then do;
  23.          /* Do some stuff here */
  24.          return TRUE; /* We did okay */ end;
  25.       DosCloseMutexSem(hmtx);  end;
  26.      DosCloseEventSem(hev3);  end;
  27.     DosCloseEventSem(hev2);  end; 
  28.    DosCloseEventSem(hev1);  end;
  29.   return FALSE;
  30.  
  31.  
  32. And I would assert my code is (1) a lot more PL/1-like and 
  33. (2) a lot easier to understand.
  34.